import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        user: {
            name: window.localStorage.getItem('user' || '[]') == null ? 'logout' : JSON.parse(window.localStorage.getItem('user' || '[]')).name,
            userFace: window.localStorage.getItem('user' || '[]') == null ? '' : JSON.parse(window.localStorage.getItem('user' || '[]')).userFace,
            userName: window.localStorage.getItem('user' || '[]') == null ? '' : JSON.parse(window.localStorage.getItem('user' || '[]')).userName
            // roles: window.localStorage.getItem('user' || '[]') == null ? '' : JSON.parse(window.localStorage.getItem('user' || '[]')).roles,
            // operator: window.localStorage.getItem('user' || '[]') == null ? '' : JSON.parse(window.localStorage.getItem('user' || '[]')).operator,
            // roleName: window.localStorage.getItem('user' || '[]') == null ? '' : JSON.parse(window.localStorage.getItem('user' || '[]')).roles[0].roleName
        },
        routes: []
    },
    mutations: {
        initMenuStore(state, menus){
            console.log(menus,'me')
            state.routes = menus
        },
        logout(state){
            window.localStorage.removeItem('user');
            state.routes = [];
        }
    },
    actions: {
        connect(context){

        }
    }

});
